package com.jijidom.order.client;

import com.jijidom.client.ProductClient;
import com.jijidom.common.DecreaseStockInput;
import com.jijidom.common.ProductInfoOutput;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Arrays;
import java.util.List;

/**
 * @author JinTao
 * @version 1.0
 * 类说明
 * @Date
 */
@RestController
@Slf4j
public class ClientController {

    @Autowired
    private ProductClient productClient;

    @GetMapping("/getProductMsg")
    public String getProductMsg(){
        String response = productClient.productMsg();
        return response;
    }

    @GetMapping("/ListForOrder")
    public String getProductList(){
        List<ProductInfoOutput> list = productClient.listForOrder(Arrays.asList("157875196366160022","157875227953464068"));
        log.info(list.toString());
        return "ok";
    }

    @GetMapping("/DecreaseStock")
    public String productDecreaseStock(){
        productClient.decreaseStock(Arrays.asList(new DecreaseStockInput("157875227953464068",3)));
        return "ok";
    }

}
